<?php
namespace app\admin\controller;
use app\admin\controller\Com;   
use think\Db;
use think\File;
use \think\Request;

class Album extends Com
{
    public function index()
    {   
        // ->alias(['album'=>'A','user'=>'U'])
        $data=Db::name('album')->join('user','user.id= zone_album.user_id')->field('zone_album.*,user.user_number')->order('zone_album.id desc')->paginate(3);
        $this->assign('data',$data);
        return view('Album/index');
    }
    public function info()
    {   
        $id=input("param.id");
        $list=Db::name('album_img')->join('album','album.id=zone_album_img.album_id')->join('user','user.id=zone_album.user_id')->field('album.title,zone_album_img.*,user.username')->where("zone_album_img.album_id=$id")->paginate(4);
       
        if (empty($list)) {
            $this->assign('list',$list);
            $this->assign('uname',$list['0']['username']);
            $this->assign('title',$list['0']['title']);
        }else{
            $this->error('该相册暂无数据');
        }
        // die();
        
        // var_dump($list);
        return view('Album/info');
    }
     public function del(){
        $id=input("param.id");

        if(Db::name('album')->where("id=$id")->delete()){
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
     }
}
